"use strict";

const path = require("node:path");
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { container } = require("webpack");

module.exports = {
  plugins: [
    new webpack.experiments.schemes.VirtualUrlPlugin({
      useRemoteEntry: {
        source: (loaderContext) => 'window.app2Url = "http://localhost:3002"',
        version: false,
      },
    }),
    new container.ModuleFederationPlugin({
      name: "appMain",
      remotes: {
        // * use `window.app2Url`
        app2: "app2@[app2Url]/solidAppRemoteEntry.js",
      },
      shared: {
        "solid-js": { singleton: true },
        "solid-js/web": { singleton: true },
      },
    }),
    new ExternalTemplateRemotesPlugin(),
  ],
};

const webpack = require("webpack");

// eslint-disable-next-line no-new
new webpack.experiments.schemes.VirtualUrlPlugin({
  myModule: 'export const msg = "from virtual module"',
});
